package org.springblade.modules.restaurant.wrapper;

import org.springblade.core.mp.support.BaseEntityWrapper;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.restaurant.entity.TaskRecord;
import org.springblade.modules.restaurant.vo.TaskRecordVO;
import org.springblade.modules.system.entity.User;
import org.springblade.modules.system.service.IUserService;


/**
 * @author harry
 * @公众号 Harry技术
 */
public class TaskRecordWrapper extends BaseEntityWrapper<TaskRecord, TaskRecordVO> {
	private static final IUserService userService;

	static {
		userService = org.springblade.core.tool.utils.SpringUtil.getBean(IUserService.class);
	}

	public static TaskRecordWrapper build() {
		return new TaskRecordWrapper();
	}

	@Override
	public TaskRecordVO entityVO(TaskRecord entity) {
		TaskRecordVO taskVO = BeanUtil.copyProperties(entity, TaskRecordVO.class);
		User user = userService.getById(entity.getCreateUser());
		if (Func.isNotEmpty(user)) {
			taskVO.setCreateUserName(user.getRealName());
		}
		return taskVO;

	}
}
